
interface MicroApp {
  [key: string]: {
    name: string
    entry: string
    container: string
    activeRule: string
  }
}

const microAppMap: MicroApp = {}

const modules = require.context(`./microApps`, true, /.*\/index\.tsx?$/)

modules.keys().forEach((key: string) => {
  const config = modules(key).default
  if (config && config.name) {
    Object.assign(microAppMap, {
      [config.name]: { ...config }
    })
  }
})

export default Object.keys(microAppMap).map(app => ({
  ...microAppMap[app],
}))

export { microAppMap }
